package com.edu.exam.enums.common;

import com.edu.exam.enums.core.BaseEnum;

/**
 * 数据状态枚举
 *
 * 通用的数据状态管理，可用于各种业务实体的状态跟踪
 *
 * @author System
 * @version 1.0.0
 */
public enum DataStatus implements BaseEnum {

    /**
     * 已接收
     */
    RECEIVED("RECEIVED", "已接收"),

    /**
     * 处理中
     */
    PROCESSING("PROCESSING", "处理中"),

    /**
     * 已处理
     */
    PROCESSED("PROCESSED", "已处理"),

    /**
     * 已评估
     */
    EVALUATED("EVALUATED", "已评估"),

    /**
     * 错误
     */
    ERROR("ERROR", "错误"),

    /**
     * 已归档
     */
    ARCHIVED("ARCHIVED", "已归档"),

    /**
     * 待处理
     */
    PENDING("PENDING", "待处理"),

    /**
     * 已完成
     */
    COMPLETED("COMPLETED", "已完成"),

    /**
     * 失败
     */
    FAILED("FAILED", "失败"),

    /**
     * 已取消
     */
    CANCELLED("CANCELLED", "已取消"),

    /**
     * 待验证
     */
    PENDING_VERIFICATION("PENDING_VERIFICATION", "待验证"),

    /**
     * 已验证
     */
    VERIFIED("VERIFIED", "已验证"),

    /**
     * 已拒绝
     */
    REJECTED("REJECTED", "已拒绝");

    private final String code;
    private final String description;

    DataStatus(String code, String description) {
        this.code = code;
        this.description = description;
    }

    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getDescription() {
        return description;
    }

    public String getJsonValue() {
        return code;
    }

    public static DataStatus fromCode(String code) {
        if (code == null || code.trim().isEmpty()) {
            return PENDING;
        }
        for (DataStatus status : values()) {
            if (status.getCode().equals(code)) {
                return status;
            }
        }
        return PENDING;
    }

    }